Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

decimal.js-light

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decimal.js-light

An arbitrary-precision Decimal type for JavaScript.

  • 2.5.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.5M
decreased by-42.67%
Maintainers
1
Weekly downloads
 
Created

What is decimal.js-light?

The decimal.js-light npm package is a library for arbitrary-precision decimal arithmetic. It allows for high-precision arithmetic operations on decimal numbers, which can be crucial in financial calculations, scientific computation, and any other domain where the precision of floating-point arithmetic is insufficient.

What are decimal.js-light's main functionalities?

Arithmetic Operations

Perform precise arithmetic operations such as addition, subtraction, multiplication, and division.

"use strict";
const Decimal = require('decimal.js-light');
let result = new Decimal('0.1').plus('0.2');
console.log(result.toString()); // '0.3'

Chaining Operations

Allows chaining of arithmetic operations for more complex calculations.

"use strict";
const Decimal = require('decimal.js-light');
let result = new Decimal('0.1').plus('0.2').minus('0.1').times('2').div('0.2');
console.log(result.toString()); // '2'

Comparison

Compare decimal numbers to determine the relative order or equality.

"use strict";
const Decimal = require('decimal.js-light');
let a = new Decimal('0.1');
let b = new Decimal('0.2');
console.log(a.lessThan(b)); // true

Rounding

Round decimal numbers to a specified number of decimal places.

"use strict";
const Decimal = require('decimal.js-light');
let result = new Decimal('0.12345').toDP(3);
console.log(result.toString()); // '0.123'

Other packages similar to decimal.js-light

Keywords

FAQs

Package last updated on 30 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc